package com.yenlien.traceyun.business.controller;

/**
 * Created by LiuSha on 2020/7/30.
 */

import com.yenlien.traceyun.business.entity.StorageManageCuring;
import com.yenlien.traceyun.business.service.StorageManageCuringService;
import com.yenlien.traceyun.webase.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/storage/manage/curing")
public class StorageManageCuringController extends BaseController {
    @Autowired
    private StorageManageCuringService storageManageService;

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public Object save(StorageManageCuring storageManage, HttpServletRequest request) throws Exception {
        List<MultipartFile> files = null;
        if (!StringUtils.isEmpty(((MultipartHttpServletRequest) request).getFile("files"))) {
            files = ((MultipartHttpServletRequest) request).getFiles("files");
        }
        storageManageService.save(storageManage, files);
        return success("success");
    }

    @RequestMapping(value = "/save2", method = RequestMethod.POST)
    public Object save2(@RequestBody StorageManageCuring storageManage) throws Exception {
        storageManageService.save2(storageManage);
        return success("success");
    }
}
